using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace @SolutionName
{
    /// <summary>
    /// Validator ensures that our properties have values set at both design time and run time
    /// </summary>
    [Serializable]
    public class @ClassNameValidator : ActivityValidator
    {
       
        public override  ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection activityErrors = base.Validate(manager, obj);
            @ClassName myActivity = obj as @ClassName;

            /* Standard properties are validated as you would expect...
            
             * if ((null != myActivity) && (null != myActivity.Parent))
            {
                if (myActivity.Property_Name == null)
                {
                    activityErrors.Add(ValidationError.GetNotSetValidationError("Property_Name"));
                }
                
            }
            
              
             If you have Dependency Properties, you need to check them a little differently, using IsBindingSet and GetValue:
             */
            if ((null != myActivity) && (null != myActivity.Parent))
                {
                    if (!myActivity.IsBindingSet(@ClassName.__ActivationPropertiesProperty))
                    {
                        if (myActivity.GetValue(@ClassName.__ActivationPropertiesProperty) == null)
                        {
                            activityErrors.Add(ValidationError.GetNotSetValidationError("__ActivationProperties"));
                        }
                    }
                }
              
             
            return activityErrors;
        }
    }
}
